<?php
class Uzytkownik_Controller extends Controller
{
	public function __construct()
	{
		parent::__construct();
                $this->session=new Session();
	}
	public function zaloz()
        {
            APPPATH."forms/SRM/Gielda/Form/ZakladanieKonta.php";
            require_once APPPATH."forms/SRM/Gielda/Form/ZakladanieKonta.php";
            $formularz_uzytkownik=new SRM_Gielda_Form_ZakladanieKonta();
            $this['user']=$formularz_uzytkownik;
            if (request::method()=="post")
            {
                $this['user']->bind($this->input->post(),$_FILES);
                if ($this['user']->isValid())
                {
                    $user=new Uzytkownik_Model();
                    $user->set_email($this->input->post('email'));
                    if ($user->sprawdz_email()==0)
                            {
                            $user->set_login($this->input->post('login'));
                            $user->set_haslo($this->input->post('haslo'));
                            $user->dodaj();
                            $this['informacja']=' !!! O K !!!';
                            }
                            else
                                {
                                $this['informacja']=' !!! N I E --O K !!!';
                            }
                    echo $this->render('account/zaloz.html');
                }
                else
                    {
                    $this['informacja']='nie ok';
                    echo $this->render('account/zaloz.html');
                    }
            }
            else
            echo $this->render('account/zaloz.html');

        }
	
}